#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int sig(int x)
{
	if (x==0) return 0;
	if(x>0)return 1;
	return -1;
}
struct Point
{
	int x,y;
	void read()
	{
		scanf("%d%d",&x,&y);
	}
	bool operator < (const Point &p) const {
			return sig(x-p.x) != 0 ? x < p.x : sig(y-p.y) < 0;
		}
	Point minus(Point b)
	{
		Point t;
		t.x=x-b.x;
		t.y=y-b.y;
		return t;
	}
};
Point p[4];
int dot(Point &o, Point &a, Point &b) {
	return (a.x-o.x)*(b.x-o.x) + (a.y-o.y)*(b.y-o.y);
}
int dot(Point a,Point b)
{
	return a.x*b.x+a.y*b.y;
}
int cross(Point a,Point b)
{
	return a.x*b.y-b.x*a.y;
}
bool Square()
{
	if(dot(p[1],p[0],p[3])==0&&dot(p[3],p[1],p[2])==0&&dot(p[2],p[3],p[0])==0&&dot(p[3].minus(p[0]),p[2].minus(p[1]))==0)
		return true;
	return false;
}
bool Rec()
{
	if(dot(p[1],p[0],p[3])==0&&dot(p[3],p[1],p[2])==0&&dot(p[2],p[3],p[0])==0)
		return true;
	return false;
}
bool Rho()
{
	if(cross(p[0].minus(p[1]),p[2].minus(p[3]))==0&&cross(p[0].minus(p[2]),p[1].minus(p[3]))==0&&dot(p[3].minus(p[0]),p[2].minus(p[1]))==0)
		return true;
	return false;
}
bool Para()
{
	if(cross(p[0].minus(p[1]),p[2].minus(p[3]))==0&&cross(p[0].minus(p[2]),p[1].minus(p[3]))==0)
		return true;
	return false;
}
bool Trap()
{
	if(cross(p[0].minus(p[1]),p[2].minus(p[3]))==0||cross(p[0].minus(p[2]),p[1].minus(p[3]))==0)
		return true;
	if(cross(p[0].minus(p[3]),p[2].minus(p[1]))==0)return true;
	return false;
}
int main()
{
	int t;
	scanf("%d",&t);

	for(int i=1;i<=t;i++)
	{
		for(int j=0;j<4;j++)p[j].read();
		sort(p,p+4);
		if(Square()){printf("Case #d: Square\n",i);continue;}
		if(Rec()){printf("Case #d: Rectangle\n",i);continue;}
		if(Rho()){printf("Case #d: Diamond\n",i);continue;}
		if(Para()){printf("Case %#d: Parallelogram\n",i);continue;}
		printf("Case %#: Others\n",i);
	}
	return 0;

}
